package conqueror.com.systemupdate.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import conqueror.com.systemupdate.R;
import conqueror.com.systemupdate.util.PreferenceUtils;

public class OnlineUpdateFragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_online_container, container, false);
        return view;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        String fragment = PreferenceUtils.getString(getActivity(), "Fragment");
        Log.e("OnlineUpdateFragment", "----PreferenceUtils---fragment--" + fragment);
        if (fragment != null && fragment.equals("OnlineDownloadFragment")) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction transaction = fragmentManager.beginTransaction();
            OnlineDownloadFragment onlineDownloadFragment = new OnlineDownloadFragment();
            transaction.replace(R.id.fl_onlineContainer, onlineDownloadFragment);
            transaction.commit();
        } else {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction transaction = fragmentManager.beginTransaction();
            OnlineCheckFragment checkFragment = new OnlineCheckFragment();
            transaction.replace(R.id.fl_onlineContainer, checkFragment);
            transaction.commit();
        }

    }

}
